package com.label.Web;


import com.label.Config.Logger.LogAnnotation;
import com.label.Model.Common.ResponseBean;
import com.label.Model.Query.ProcessQuery;
import com.label.Service.LabelService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.eclipse.jetty.http.HttpStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/label")
public class LabelController {

    private final static Logger logger = LoggerFactory.getLogger(LabelController.class);

    @Resource
    private LabelService labelService;

    @RequestMapping(value = "/getLike")
    @LogAnnotation(module = "LABEL模块",operator = "模糊查询")
    @RequiresAuthentication
    public ResponseBean getLike(@RequestParam(name = "id")Integer id, @RequestParam(name = "str")String str) {
        try{
            return new ResponseBean(HttpStatus.OK_200,"成功！",labelService.getLike(id,str));
        }catch (Exception e){
            logger.info(e.getMessage());
            return new ResponseBean(HttpStatus.INTERNAL_SERVER_ERROR_500,"失败！",null);
        }
    }

    @RequestMapping(value = "/getLabel")
    @LogAnnotation(module = "LABEL模块",operator = "获取所有label")
    @RequiresAuthentication
    public ResponseBean getLabel(){
        return new ResponseBean(HttpStatus.OK_200,"成功！",labelService.getLabel());
    }

    @RequestMapping("/getCardLabel")
    @LogAnnotation(module = "LABEL模块",operator = "获取画像label")
    @RequiresAuthentication
    public ResponseBean getCardLabel(@RequestBody ProcessQuery processQuery ) {
        return new ResponseBean(HttpStatus.OK_200,"成功！",labelService.getCardLabel(processQuery.getTheme()));
    }



}
